package com.zbkj.dal.feign;

import com.zbkj.dal.feign.req.EmployeeListReq;
import com.zbkj.dal.feign.req.QrcodeReq;
import com.zbkj.dal.feign.req.RobotMessage;
import com.zbkj.dal.feign.req.WeWorkUpdateUserReq;
import com.zbkj.dal.feign.vo.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * @author JXY
 */
@FeignClient(name = "we-work", url = "https://qyapi.weixin.qq.com")
public interface WeWorkFeign {
    /**
     * 获取token
     *
     * @param corpId     corpId
     * @param corpSecret corpSecret
     * @return {@link ResponseEntity}<{@link Map}>
     */
    @GetMapping("/cgi-bin/gettoken")
    WeWorkTokenVO getToken(@RequestParam("corpid") String corpId, @RequestParam("corpsecret") String corpSecret);


    /**
     * 读取成员
     *
     * @param token  token
     * @param userid 微信userId
     * @return {@link WeWorkUserInfoVO}
     */
    @GetMapping("/cgi-bin/user/get")
    WeWorkUserInfoVO weWorkUserInfo(@RequestParam("access_token") String token, @RequestParam("userid") String userid);

    /**
     * 获取联系我二维码
     *
     * @param token     token
     * @param qrcodeReq 获取联系我二维码参数
     * @return {@link Object}
     */
    @PostMapping("/cgi-bin/externalcontact/add_contact_way")
    ContactMeVO qrcode(@RequestParam("access_token") String token, @RequestBody QrcodeReq qrcodeReq);

    /**
     * 成员列表
     *
     * @param token token
     * @param req   req
     * @return {@link EmployeeListVO}
     */
    @PostMapping("/cgi-bin/user/list_id")
    EmployeeListVO employeeList(@RequestParam("access_token") String token, @RequestBody EmployeeListReq req);

    /**
     * 更新成员
     */
    @PostMapping("/cgi-bin/user/update")
    BaseResponse updateUser(@RequestParam("access_token") String token, @RequestBody WeWorkUpdateUserReq weWorkUpdateUserReq);

    /**
     * 删除成员
     */
    @GetMapping("/cgi-bin/user/delete")
    BaseResponse deleteUser(@RequestParam("access_token") String token, @RequestParam("userid") String userid);

    @GetMapping("/cgi-bin/webhook/send?key=")
    Object sendMessage(@RequestParam("key") String key, @RequestBody RobotMessage robotMessage);

}
